package com.ruoyi.healthCard.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.healthCard.domain.TBizPhysicalPerson;
import com.ruoyi.healthCard.service.ITBizPhysicalPersonService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 体检人员登记Controller
 * 
 * @author ruoyi
 * @date 2025-06-20
 */
@RestController
@RequestMapping("/health/person")
public class TBizPhysicalPersonController extends BaseController
{
    @Autowired
    private ITBizPhysicalPersonService tBizPhysicalPersonService;

    /**
     * 查询体检人员登记列表
     */
    @PreAuthorize("@ss.hasPermi('health:person:list')")
    @GetMapping("/list")
    public TableDataInfo list(TBizPhysicalPerson tBizPhysicalPerson)
    {
        startPage();
        List<TBizPhysicalPerson> list = tBizPhysicalPersonService.selectTBizPhysicalPersonList(tBizPhysicalPerson);
        return getDataTable(list);
    }

    /**
     * 导出体检人员登记列表
     */
    @PreAuthorize("@ss.hasPermi('health:person:export')")
    @Log(title = "体检人员登记", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TBizPhysicalPerson tBizPhysicalPerson)
    {
        List<TBizPhysicalPerson> list = tBizPhysicalPersonService.selectTBizPhysicalPersonList(tBizPhysicalPerson);
        ExcelUtil<TBizPhysicalPerson> util = new ExcelUtil<TBizPhysicalPerson>(TBizPhysicalPerson.class);
        util.exportExcel(response, list, "体检人员登记数据");
    }

    /**
     * 获取体检人员登记详细信息
     */
    @PreAuthorize("@ss.hasPermi('health:person:query')")
    @GetMapping(value = "/{personId}")
    public AjaxResult getInfo(@PathVariable("personId") Long personId)
    {
        return success(tBizPhysicalPersonService.selectTBizPhysicalPersonByPersonId(personId));
    }

    /**
     * 新增体检人员登记
     */
    @PreAuthorize("@ss.hasPermi('health:person:add')")
    @Log(title = "体检人员登记", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TBizPhysicalPerson tBizPhysicalPerson)
    {
        return toAjax(tBizPhysicalPersonService.insertTBizPhysicalPerson(tBizPhysicalPerson));
    }

    /**
     * 修改体检人员登记
     */
    @PreAuthorize("@ss.hasPermi('health:person:edit')")
    @Log(title = "体检人员登记", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TBizPhysicalPerson tBizPhysicalPerson)
    {
        return toAjax(tBizPhysicalPersonService.updateTBizPhysicalPerson(tBizPhysicalPerson));
    }

    /**
     * 删除体检人员登记
     */
    @PreAuthorize("@ss.hasPermi('health:person:remove')")
    @Log(title = "体检人员登记", businessType = BusinessType.DELETE)
	@DeleteMapping("/{personIds}")
    public AjaxResult remove(@PathVariable Long[] personIds)
    {
        return toAjax(tBizPhysicalPersonService.deleteTBizPhysicalPersonByPersonIds(personIds));
    }
}
